/**
 * Created by zhaoyanzhi on 16-9-8.
 */
function Control(){
    this.goodsInfo=JSON.parse(localStorage.getItem("goodsInfo"))||{};
}
Control.prototype.changeCartListInfo=function(product,num){
    var cartList=this.goodsInfo.cartList||{};
    if(product.itemName  in  cartList){
        var  itemInfo=Item.computeItemCount(cartList[product.itemName],num);
        var  itemInfo=Item.computeCostPrice(itemInfo);
        var  promotion=new Promotion();
        var  itemInfo=promotion.computePromotionCount(itemInfo);
        var  itemInfo=promotion.computeSavePrice(itemInfo);
        var  itemInfo=ShoppingCart.computeActuallyPaid(itemInfo);
    }else{
        var  itemInfo=ShoppingCart.addProduct(product);
    }
    cartList[product.itemName]=itemInfo;
    return  cartList
};
Control.prototype.saveGoodsInfo=function(cartList){
    this.goodsInfo.cartList=cartList;
    localStorage.setItem("goodsInfo",JSON.stringify(this.goodsInfo));
}


